<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>批改作业 - 析码无界</title>
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.4/css/bootstrap.min.css">
    <link rel="stylesheet" href="http://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <script src="http://cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></script>
    <script src="http://cdn.bootcss.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
    <style>
        body {
            font-family: 'Microsoft YaHei', sans-serif;
            background-color: #f5f5f5;
            padding-top: 20px;
        }
        .panel {
            border: none;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            border-radius: 8px;
        }
        .panel-heading {
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            color: white;
            border-radius: 8px 8px 0 0;
        }
        .btn-primary {
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            border: none;
        }
        .student-info {
            background-color: #f8f9fa;
            padding: 15px;
            border-radius: 5px;
            margin-bottom: 20px;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title"><i class="fa fa-check-circle"></i> 批改作业</h3>
            </div>
            <div class="panel-body">
                <div th:if="${message}" class="alert alert-success" th:text="${message}"></div>
                <div th:if="${error}" class="alert alert-danger" th:text="${error}"></div>
                
                <!-- 作业信息 -->
                <div class="panel panel-info">
                    <div class="panel-heading">
                        <h4 class="panel-title">作业信息</h4>
                    </div>
                    <div class="panel-body">
                        <p><strong>作业标题：</strong><span th:text="${assignment?.title}"></span></p>
                        <p><strong>作业内容：</strong></p>
                        <div th:text="${assignment?.content}" style="white-space: pre-wrap; background-color: #fff; padding: 10px; border-radius: 4px;"></div>
                    </div>
                </div>
                
                <!-- 学生提交内容 -->
                <div class="panel panel-success">
                    <div class="panel-heading">
                        <h4 class="panel-title">学生提交内容</h4>
                    </div>
                    <div class="panel-body">
                        <p th:if="${submission?.content != null and submission.content != ''}">
                            <strong>提交内容：</strong>
                        </p>
                        <div th:if="${submission?.content != null and submission.content != ''}" 
                             th:text="${submission.content}" 
                             style="white-space: pre-wrap; background-color: #fff; padding: 10px; border-radius: 4px; margin-bottom: 15px;"></div>
                        
                        <p th:if="${submission?.fileName != null}">
                            <strong>提交文件：</strong>
                            <a th:href="@{'/uploads/assignments/' + ${submission.fileName}}" 
                               th:text="${submission.fileName}"
                               target="_blank">
                                <i class="fa fa-download"></i> 下载文件
                            </a>
                        </p>
                        
                        <p th:if="${submission?.submitTime != null}">
                            <strong>提交时间：</strong>
                            <span th:text="${#dates.format(submission.submitTime, 'yyyy-MM-dd HH:mm:ss')}"></span>
                        </p>
                    </div>
                </div>
                
                <!-- 批改表单 -->
                <form th:action="@{/assignment/grade}" method="post">
                    <input type="hidden" name="submissionId" th:value="${submission?.id}"/>
                    
                    <div class="form-group">
                        <label>评分 <span style="color: red;">*</span></label>
                        <input type="number" class="form-control" name="score" 
                               th:value="${submission?.score}"
                               min="0" max="100" required placeholder="请输入分数（0-100）">
                        <small class="help-block">分数范围：0-100</small>
                    </div>
                    
                    <div class="form-group">
                        <label>评语</label>
                        <textarea class="form-control" name="comment" rows="5" 
                                  placeholder="请输入评语..." th:text="${submission?.comment}"></textarea>
                    </div>
                    
                    <div class="form-group">
                        <button type="submit" class="btn btn-primary">
                            <i class="fa fa-save"></i> 保存批改
                        </button>
                        <a th:href="@{/class/studentStatus(classId=${assignment.classId}, assignmentId=${assignment.id})}" 
                           class="btn btn-default">
                            <i class="fa fa-arrow-left"></i> 返回
                        </a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</body>
</html>

